from rest_framework import serializers

from goods.models import GoodsChannel, GoodsCategory, GoodsChannelGroup


class GoodsChannelSerializer(serializers.ModelSerializer):
    """
       GoodsChannel表序列化器
    """
    group =serializers.StringRelatedField(read_only=True)
    group_id=serializers.IntegerField()

    category=serializers.StringRelatedField(read_only=True)
    category_id=serializers.IntegerField()

    class Meta:
        model = GoodsChannel
        fields = '__all__'



class GoodsCategorySerializer(serializers.ModelSerializer):
    """
       GoodsCategory表序列化器
    """

    class Meta:
        model = GoodsCategory
        fields = '__all__'


class GoodsChannelGroupSerializer(serializers.ModelSerializer):
    """
       GoodsChannelGroup表序列化器
    """

    class Meta:
        model = GoodsChannelGroup
        fields = '__all__'
